<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>价格监控 - 雁农冷链平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="../../static/kj/vue.min.js"></script>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Microsoft YaHei', Arial, sans-serif;
            background-color: #f5f5f5;
            color: #333;
        }
        
        .container {
            padding: 20px;
            max-width: 1200px;
            margin: 0 auto;
        }
        
        .page-header {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }
        
        .page-title {
            font-size: 24px;
            font-weight: bold;
            color: #2c3e50;
            margin-bottom: 10px;
        }
        
        .page-desc {
            color: #7f8c8d;
            font-size: 14px;
        }
        
        .filter-section {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            margin-bottom: 20px;
        }
        
        .filter-row {
            display: flex;
            gap: 20px;
            align-items: center;
            margin-bottom: 15px;
        }
        
        .filter-item {
            display: flex;
            align-items: center;
            gap: 10px;
        }
        
        .filter-label {
            font-weight: bold;
            color: #34495e;
            min-width: 80px;
        }
        
        .form-control {
            padding: 8px 12px;
            border: 1px solid #ddd;
            border-radius: 4px;
            font-size: 14px;
            min-width: 150px;
        }
        
        .btn {
            padding: 8px 16px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            font-size: 14px;
            transition: all 0.3s;
        }
        
        .btn-primary {
            background-color: #3498db;
            color: white;
        }
        
        .btn-primary:hover {
            background-color: #2980b9;
        }
        
        .btn-success {
            background-color: #27ae60;
            color: white;
        }
        
        .btn-success:hover {
            background-color: #229954;
        }
        
        .stats-grid {
            display: grid;
            grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
            gap: 20px;
            margin-bottom: 20px;
        }
        
        .stat-card {
            background: white;
            padding: 20px;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            text-align: center;
        }
        
        .stat-icon {
            font-size: 32px;
            margin-bottom: 10px;
        }
        
        .stat-title {
            font-size: 14px;
            color: #7f8c8d;
            margin-bottom: 5px;
        }
        
        .stat-value {
            font-size: 24px;
            font-weight: bold;
            color: #2c3e50;
        }
        
        .price-table {
            background: white;
            border-radius: 8px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            overflow: hidden;
        }
        
        .table-header {
            background: #34495e;
            color: white;
            padding: 15px 20px;
            font-weight: bold;
        }
        
        .table {
            width: 100%;
            border-collapse: collapse;
        }
        
        .table th,
        .table td {
            padding: 12px 15px;
            text-align: left;
            border-bottom: 1px solid #eee;
        }
        
        .table th {
            background: #f8f9fa;
            font-weight: bold;
            color: #2c3e50;
        }
        
        .table tbody tr:hover {
            background-color: #f8f9fa;
        }
        
        .price-up {
            color: #e74c3c;
        }
        
        .price-down {
            color: #27ae60;
        }
        
        .price-stable {
            color: #95a5a6;
        }
        
        .trend-icon {
            margin-left: 5px;
        }
        
        .alert {
            padding: 12px 15px;
            border-radius: 4px;
            margin-bottom: 20px;
        }
        
        .alert-info {
            background-color: #d1ecf1;
            border: 1px solid #bee5eb;
            color: #0c5460;
        }
    </style>
</head>
<body>
    <div id="app" class="container">
        <!-- 页面标题 -->
        <div class="page-header">
            <div class="page-title">📊 价格监控</div>
            <div class="page-desc">实时监控衡阳地区农产品市场价格变化，掌握本地供需动态</div>
        </div>
        
        <!-- 筛选条件 -->
        <div class="filter-section">
            <div class="filter-row">
                <div class="filter-item">
                    <label class="filter-label">商品类型:</label>
                    <select v-model="filters.category" class="form-control">
                        <option value="">全部类型</option>
                        <option value="衡阳特产">衡阳特产</option>
                        <option value="蔬菜">蔬菜</option>
                        <option value="水果">水果</option>
                        <option value="粮油">粮油</option>
                        <option value="禽蛋">禽蛋</option>
                    </select>
                </div>
                <div class="filter-item">
                    <label class="filter-label">地区:</label>
                    <select v-model="filters.region" class="form-control">
                        <option value="">全部地区</option>
                        <option value="衡阳市蒸湘区">衡阳市蒸湘区</option>
                        <option value="衡阳市珠晖区">衡阳市珠晖区</option>
                        <option value="衡阳市雁峰区">衡阳市雁峰区</option>
                        <option value="衡阳市石鼓区">衡阳市石鼓区</option>
                        <option value="衡阳市南岳区">衡阳市南岳区</option>
                    </select>
                </div>
                <div class="filter-item">
                    <label class="filter-label">时间范围:</label>
                    <select v-model="filters.timeRange" class="form-control">
                        <option value="today">今日</option>
                        <option value="week">本周</option>
                        <option value="month">本月</option>
                        <option value="quarter">本季度</option>
                    </select>
                </div>
                <button @click="searchPrices" class="btn btn-primary">🔍 查询</button>
                <button @click="exportData" class="btn btn-success">📊 导出数据</button>
            </div>
        </div>
        
        <!-- 统计卡片 -->
        <div class="stats-grid">
            <div class="stat-card">
                <div class="stat-icon">📈</div>
                <div class="stat-title">今日涨幅商品</div>
                <div class="stat-value">{{ stats.upCount }}</div>
            </div>
            <div class="stat-card">
                <div class="stat-icon">📉</div>
                <div class="stat-title">今日跌幅商品</div>
                <div class="stat-value">{{ stats.downCount }}</div>
            </div>
            <div class="stat-card">
                <div class="stat-icon">💰</div>
                <div class="stat-title">平均价格</div>
                <div class="stat-value">¥{{ stats.avgPrice }}</div>
            </div>
            <div class="stat-card">
                <div class="stat-icon">🔄</div>
                <div class="stat-title">更新时间</div>
                <div class="stat-value">{{ stats.updateTime }}</div>
            </div>
        </div>
        
        <!-- 价格监控提醒 -->
        <div class="alert alert-info">
            💡 <strong>提示：</strong>价格数据每30分钟更新一次，如需实时数据请联系客服开通高级服务
        </div>
        
        <!-- 价格表格 -->
        <div class="price-table">
            <div class="table-header">
                💹 实时价格监控表
            </div>
            <table class="table">
                <thead>
                    <tr>
                        <th>商品名称</th>
                        <th>类型</th>
                        <th>地区</th>
                        <th>当前价格(元/kg)</th>
                        <th>昨日价格</th>
                        <th>涨跌幅</th>
                        <th>供应量</th>
                        <th>需求量</th>
                        <th>更新时间</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="item in priceList" :key="item.id">
                        <td>{{ item.name }}</td>
                        <td>{{ item.category }}</td>
                        <td>{{ item.region }}</td>
                        <td>¥{{ item.currentPrice }}</td>
                        <td>¥{{ item.yesterdayPrice }}</td>
                        <td :class="getPriceClass(item.change)">
                            {{ item.change }}%
                            <span class="trend-icon">{{ getTrendIcon(item.change) }}</span>
                        </td>
                        <td>{{ item.supply }}吨</td>
                        <td>{{ item.demand }}吨</td>
                        <td>{{ item.updateTime }}</td>
                        <td>
                            <button @click="viewTrend(item)" class="btn btn-primary" style="font-size: 12px; padding: 4px 8px;">📈 趋势</button>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    
    <script>
        new Vue({
            el: '#app',
            data: {
                filters: {
                    category: '',
                    region: '',
                    timeRange: 'today'
                },
                stats: {
                    upCount: 23,
                    downCount: 15,
                    avgPrice: '12.5',
                    updateTime: '10:30'
                },
                priceList: [
                    {
                        id: 1,
                        name: '衡阳湘莲',
                        category: '衡阳特产',
                        region: '衡阳市蒸湘区',
                        currentPrice: 32.0,
                        yesterdayPrice: 30.0,
                        change: 6.7,
                        supply: 120,
                        demand: 150,
                        updateTime: '10:25'
                    },
                    {
                        id: 2,
                        name: '衡阳黄花菜',
                        category: '衡阳特产',
                        region: '衡阳市祁东县',
                        currentPrice: 45.0,
                        yesterdayPrice: 48.0,
                        change: -6.3,
                        supply: 80,
                        demand: 90,
                        updateTime: '10:20'
                    },
                    {
                        id: 3,
                        name: '衡阳茶油',
                        category: '粮油',
                        region: '衡阳市南岳区',
                        currentPrice: 88.0,
                        yesterdayPrice: 88.0,
                        change: 0,
                        supply: 50,
                        demand: 55,
                        updateTime: '10:15'
                    },
                    {
                        id: 4,
                        name: '衡阳大白菜',
                        category: '蔬菜',
                        region: '衡阳市珠晖区',
                        currentPrice: 6.5,
                        yesterdayPrice: 6.0,
                        change: 8.3,
                        supply: 200,
                        demand: 180,
                        updateTime: '10:10'
                    },
                    {
                        id: 5,
                        name: '衡阳土鸡蛋',
                        category: '禽蛋',
                        region: '衡阳市雁峰区',
                        currentPrice: 32.0,
                        yesterdayPrice: 34.0,
                        change: -5.9,
                        supply: 150,
                        demand: 160,
                        updateTime: '10:05'
                    },
                    {
                        id: 6,
                        name: '衡阳白萄萄',
                        category: '水果',
                        region: '衡阳市石鼓区',
                        currentPrice: 25.0,
                        yesterdayPrice: 23.0,
                        change: 8.7,
                        supply: 60,
                        demand: 70,
                        updateTime: '10:00'
                    }
                ]
            },
            methods: {
                searchPrices() {
                    alert('正在查询价格数据...');
                    // 这里可以添加实际的查询逻辑
                },
                exportData() {
                    alert('正在导出价格数据...');
                    // 这里可以添加导出功能
                },
                viewTrend(item) {
                    alert(`查看 ${item.name} 的价格趋势图`);
                    // 这里可以跳转到趋势详情页面
                },
                getPriceClass(change) {
                    if (change > 0) return 'price-up';
                    if (change < 0) return 'price-down';
                    return 'price-stable';
                },
                getTrendIcon(change) {
                    if (change > 0) return '↗';
                    if (change < 0) return '↘';
                    return '→';
                }
            },
            mounted() {
                // 页面加载完成后的初始化操作
                console.log('价格监控页面已加载');
            }
        });
    </script>
</body>
</html>